/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Sphere;

/**
 *
 * @author Eden
 */
public final class Ball extends Node {
    
    private Geometry sphere;
    private AssetManager assetManager;
    public Ball(AssetManager assetManager, float size)
    {
        super("Ball");
        this.assetManager = assetManager; 
        Sphere s = new Sphere(32, 32, size);
        sphere = new Geometry("Ball", s);
        sphere.setLocalTranslation(0, -1, 2);
        initMaterial();

    }
    void initMaterial()
    {
        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        mat.setBoolean("UseMaterialColors", true);
        mat.setColor("Ambient", new ColorRGBA(188f / 255f, 198f / 255f, 204f / 255f, 1));
        mat.setColor("Diffuse", new ColorRGBA(188f / 255f, 198f / 255f, 204f / 255f, 1));
        mat.setColor("Specular", ColorRGBA.White);
        mat.setFloat("Shininess", 8);    // [0,128]
        mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
        mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
        sphere.setMaterial(mat);
        attachChild(sphere);
    }
    
}
